<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        body,
        html {
            width: 100%;
            height: 100%;
        }
        
        .box {
            width: 100%;
            height: 0px;
            overflow: hidden;
            display: flex;
            justify-content: space-around;
            background: #ccc;
            align-items: center;
            transition: 1s;
        }
        
        .box img {
            width: 300px;
            height: 200px;
        }
        
        .active {
            height: 200px;
            transition: 0.5s;
        }
    </style>
</head>

<body>
    <div class="box">
        <img src="./images/1.jpg" alt="">
        <img src="./images/2.jpg" alt="">
        <img src="./images/3.jpg" alt="">
    </div>
    <button id='btn'>换肤</button>

    <script>
        //获取需要的元素
        var box = document.querySelector('.box')
        var btn = document.querySelector('#btn')

        //给按钮添加点击事件
        btn.onclick = function() {
            box.classList.toggle('active');
        }

        //给盒子添加点击事件
        box.onclick = function(e) {
            var e = e || window.event;
            // 引入图片
            document.body.style.background = 'url(' + e.target.src + ') no-repeat center center /100% 100%';
            //有图片出来后让box隐藏
            box.classList.toggle('active');
        }
    </script>

</body>

</html>